﻿//新增标签列表
InsertNormal_TagMap = function() {
    var InsertNormal_TagMapForm = Ext.create("Ext.form.Panel", {
        width: 360,
        height: 450,
        plain: true,
        autoScroll: true, 
        layout: "anchor",
        defaultType: "textfield",
        labelWidth: 55,
        baseCls: "x-plain",
        defaults: { labelAlign: 'right', anchor: '90%', msgTarget: "side" },
        buttonAlign: "center",
        bodyStyle: "padding:0 0 0 0",
        items: [{
                        name: "TagId",
            fieldLabel: "<font color='red'>*</font>",
            allowBlank: false,
            blankText: "不能为空",
            regex: /^[\d]{0,10}$/,
            regexText: "请填写0～10个数字"
        }, {
            name: "ModuleId",
            fieldLabel: "<font color='red'>*</font>内容Id",
            allowBlank: false,
            blankText: "内容Id不能为空",
            regex: /^[\d]{0,10}$/,
            regexText: "请填写0～10个数字"
        }, {
            name: "ModuleType",
            fieldLabel: "内容类型",
            regex: /^[\da-zA-Z]{0,9}$/,
            regexText: "请填写0～9个数字或字母"
        }
			]
    });


    var InsertNormal_TagMapWin = Ext.create('Ext.window.Window', {
        title: "新增标签列表",
        width: 400,
        height: 450,
        plain: true,
        layout: "fit",
        //不可以随意改变大小
        resizable: false,
        //是否可以拖动
        //draggable:false,
        defaultType: "textfield",
        collapsible: true, //允许缩放条
        closeAction: 'hide',
        closable: true,
        //弹出模态窗体
        modal: 'true',
        buttonAlign: "center",
        bodyStyle: "padding:10px 0 0 15px",
        items: [InsertNormal_TagMapForm],

        buttons: [{
            text: "保存信息",
            minWidth: 70,
            handler: function() {
                //alert(InsertNormal_TagMapForm.getForm().isValid())
                if (InsertNormal_TagMapForm.getForm().isValid()) {
                    //弹出效果 Ext.MessageBox.alert("asdf");
                    Ext.MessageBox.show
                                (
                                    {
                                        msg: '正在保存，请稍等...',
                                        progressText: 'Saving...',
                                        width: 300,
                                        wait: true,
                                        waitConfig: { interval: 200 },
                                        icon: 'download',
                                        animEl: 'saving'
                                    }
                                );
                    setTimeout(function() { }, 1000);
                    InsertNormal_TagMapForm.form.submit({
                        url: "/manager/Normal_TagMap/Insert/",
                        method: "POST",
                        success: function(form, action) {
                            //成功后
                            var flag = action.result.success;
                            if (flag == "true") {
                                Normal_TagMapStore.loadPage(1);
                                Ext.MessageBox.alert("恭喜", "新增成功!");
                                InsertNormal_TagMapWin.hide();
                            }
                            else {
                                var message = action.result.message;
                                if (message) {
                                    Ext.MessageBox.alert("新增失败!", message);
                                }
                                else {
                                    Ext.MessageBox.alert("提示!", "新增失败!");
                                    InsertNormal_TagMapWin.hide();
                                }

                            }
                        },
                        failure: function(form, action) {
                            Ext.MessageBox.alert("提示!", "新增失败!");
                        }
                    });
                }
            }
        }, {
            text: "重置",
            minWidth: 70,
            qtip: "重置数据",
            handler: function() {
                //加载表单数据
                InsertNormal_TagMapForm.getForm().reset();
            }
        }, {
            text: "取 消",
            minWidth: 70,
            handler: function() {
                InsertNormal_TagMapWin.hide();
            }
}]

        });

        InsertNormal_TagMapWin.show();
    }
